<template>
  <view class="content">
    <view class="image-content">
      <image
        style="width: 100%"
        mode="widthFix"
        src="https://check-in.wuming-adv.info/top-header.jpg"
      ></image>
      <view class="rank-num"></view>
      <view class="num">
        <view class="list">访问量：{{ sumData.accessCount || '' }}</view>
        <view class="list">打卡量：{{ sumData.articleCount || '' }}</view>
        <view class="list">参与者：{{ sumData.userCount || '' }}</view>
      </view>
    </view>
    <view class="list-area">
      <scroll-view scroll-y="true" class="scroll-Y">
        <view class="list-tag" v-for="(item, index) in rankData" :key="index">
          <view class="num gold" v-if="index === 0">{{ index + 1 }}</view>
          <view class="num silver" v-else-if="index === 1">{{ index + 1 }}</view>
          <view class="num copper" v-else-if="index === 2">{{ index + 1 }}</view>
          <view class="num" v-else>{{ index + 1 }}</view>
          <view class="bet">
            <view class="img">
              <image style="width: 90rpx; height: 90rpx" :src="item.avatarUrl"></image>
            </view>
            <view class="name">
              <view class="title">{{ item.userName }}</view>
              <view class="sub">学校名称：{{ item.schoolName }}</view>
            </view>
          </view>
          <view class="qty">
            <text class="nu">{{ item.allCount }}</text>
            次
          </view>
        </view>
      </scroll-view>
    </view>
    <GModal :value="showModal" title="活动须知" buttonText="接受" :content="content" @cancel="showModal=false" @confirm="acceptLawFun" />
  </view>
</template>

<script>
import { rankList, sumData } from '@/api/yuedu'
import { acceptLaw } from '@/api/user'
import GModal from '@/components/ithui-bullet/ithui-bullet-two.vue'
export default {
  components: {
    GModal
  },
  data() {
    return {
      showModal: false,
      content: `
		<div>（一）合法性原则：上传资料必须符合国家法律法规，不得侵犯他人合法权益，不得传播违法信息，不得包含庸俗、暴力、消极等内容。</div>
		<div>（二）真实性原则：上传资料应当真实可靠，不得虚构、篡改、误导。 </div>
		<div>（三）合规性原则：上传资料应符合平台相关管理规定，不得违反平台政策，符合相关标准，不得有损平台形象。</div>
		<div>（四）材料类型：包括文本、图片、音视频等，不得涉及国家机密、侵犯他人合法权益、传播违法信息。提交材料内容必须是科幻文学类作品或者讲述科幻阅读心得体会。</div>
		<div>（五）质量要求：上传资料应具有较高的质量，视频/音频时长大于等于2分钟，小于等于5分钟。拍摄画面清晰，镜头运用流畅、结构完整、画质清晰，视频大小不超过500MB。音频必须吐字清晰，每天可打卡多次，只计为1次。</div></div>
		<div>（六）违规制度：平台管理员定期对上传内容进行审核，有权对不合规等打卡内容进行删除，删除后不计入打卡评审内容。</div>
		<div>（七）奖励制度：每日参加打卡者，在上传作品以后均有机会获取打卡小红包，但每天只能获取1次。连续打卡10次可获取打卡中红包，连续打卡25次可获取打卡大红包。</div>
		<div>（八）评优制度：组织方会在连续打卡25天阅读参与者中，选取作品完成度高，视频拍摄精美者，综合评定10人，奖励价值200元读书卡一张，前20名可以免费参加暑期科普研学班。</div>
		<div>（九）提现制度：打卡者账户里的可申请提现到微信零钱，每天最多提现1次。每次提现金额不少于0.1元，请合理规划提现金额。</div>`,
	rankData: [],
      sumData: {},
      rateValue: 0
    }
  },
  computed: {
    userInfo() {
      return this.$store.getters.userInfo
    },
    isLogin() {
      return this.$store.getters.token
    }
  },
  watch: {
    isLogin: {
      handler(data) {
        if (data && !this.userInfo.acceptTime) {
          this.showModal = true
        }
      },
      immediate: true
    }
  },
  onLoad() {
    this.getData()
  },
  methods: {
    acceptLawFun() {
      this.showModal = false
      acceptLaw()
    },
    getData() {
      rankList().then((res) => {
        if (res.code === 200) {
          this.rankData = res.rows
        }
      }),
        sumData().then((res) => {
          if (res.code === 200) {
            this.sumData = res.data
          }
        })
    },
    navigateTo(url) {
      uni.navigateTo({
        url
      })
    },
    toDetail() {
      uni.navigateTo({
        url: '/pagesSub/detail/self'
      })
    }
  }
}
</script>

<style lang="less" scoped>
.content {
  display: flex;
  flex-direction: column;
  height: 100vh;
}
.list-area {
  flex: 1;
  overflow: hidden;
}
.image-content {
  position: relative;
  .rank-num {
    position: absolute;
    width: 100%;
    height: 50rpx;
    left: 0;
    bottom: 8rpx;
    background-color: #000;
    opacity: 0.6;
  }
  .num {
    position: absolute;
    width: 100%;
    height: 40rpx;
    left: 0;
    bottom: 8rpx;
    z-index: 10;
    font-size: 13px;
    display: flex;
    justify-content: space-between;
    .list {
      padding: 0 20rpx;
      color: #fff;
    }
  }
}
.scroll-Y {
  height: 100%;
}
.list-tag {
  display: flex;
  align-items: center;
  padding: 20rpx 10rpx;
  border-bottom: 1px #dbdbdb solid;
  background-color: #fff;
  .num {
    width: 50rpx;
    height: 50rpx;
    font-weight: bold;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 50%;
    margin-right: 20rpx;
    &.gold {
      color: #fff;
      border: 1px #e3e3e3 solid;
      background: linear-gradient(to bottom, #ffd700, #e9c03b);
    }
    &.silver {
      color: #fff;
      border: 1px #e3e3e3 solid;
      background: linear-gradient(to bottom, #f5f5f5, #e1e1e1);
    }
    &.copper {
      color: #fff;
      border: 1px #e3e3e3 solid;
      background: linear-gradient(to bottom, #e79141, #d78448);
    }
  }
  .bet {
    flex: 1;
    display: flex;
    align-items: center;
    .img {
      width: 90rpx;
      height: 90rpx;
      border-radius: 50%;
      border: 1px #ccc solid;
      overflow: hidden;
    }
    .name {
      margin-left: 20rpx;
      .title {
        font-weight: bold;
        font-size: 15px;
      }
      .sub {
        font-size: 13px;
        color: #666;
      }
    }
  }
  .qty {
    width: 120rpx;
    .nu {
      font-size: 18px;
      font-weight: bold;
      color: #fc7110;
      padding-right: 10rpx;
    }
  }
}
</style>
